package com.android.lovingpet;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;

import com.android.lovingpet.bean.GuideAdapter;
import com.android.lovingpet.signin.view.SignInActivity;
import com.android.lovingpet.signup.view.LoginInActivity;

import java.util.ArrayList;
import java.util.List;


public class StartActivity extends AppCompatActivity implements View.OnClickListener{
    public Button bt2;
    public Button bt1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_start);
        bt1=findViewById(R.id.login_in);
        bt2=findViewById(R.id.sign_in);
        bt1.setOnClickListener(this);
        bt2.setOnClickListener(this);
        //注册广播
        IntentFilter intentFilter=new IntentFilter();
        intentFilter.addAction("exitActivity");
        this.registerReceiver(this.broadcastReceiver,intentFilter);

        //获取适配器
        List<Integer> images = new ArrayList<>(3);
        images.add(R.drawable.guide_1_anim_24);
        images.add(R.drawable.guide_2_anim_24);
        images.add(R.drawable.guide_3_anim_24);
        GuideAdapter mGuideAdapter = new GuideAdapter(images, this);
//获取ViewPager控件
        ViewPager mGuideVp = findViewById(R.id.guide_pages);
//设置适配器
        mGuideVp.setAdapter(mGuideAdapter);
}
    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.login_in:
                Intent intent=new Intent(StartActivity.this,LoginInActivity.class);
                startActivity(intent);
                break;
            case R.id.sign_in:
                Intent intent1=new Intent(StartActivity.this,SignInActivity.class);
                startActivity(intent1);
                break;
            default:
                break;
        }
    }

    protected BroadcastReceiver broadcastReceiver=new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            finish();
        }
    };

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.unregisterReceiver(this.broadcastReceiver);
    }
}
